<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>后台管理</title>
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/layui/css/layui.css" />
<link rel="stylesheet" type="text/css" href="__STATIC__/admin/css/admin.css" />
<style>
.layui-form-label{ width:130px;}
.layui-input-block{ margin-left:160px;}
.pic_box{ padding-top:10px;}
</style>
</head>
<body>
<div class="wrap-container">
  <form class="layui-form edit-form" method="post" action="{:url()}" style="width: 90%;padding-top: 20px;">
    {present name="info.id"}
    <input type="hidden" name="id" value="{$info.id|default=''}" />
    {/present}
    
    
    <div class="layui-form-item">
      <label class="layui-form-label">广告标题：</label>
      <div class="layui-input-block">
        <input type="text" name="title" value="{$info.title|default=''}" required lay-verify="required" placeholder="请输入广告标题" autocomplete="off" class="layui-input">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">广告链接：</label>
      <div class="layui-input-block">
        <input type="text" name="url" value="{$info.url|default=''}" required lay-verify="required" placeholder="请输入广告链接" autocomplete="off" class="layui-input">
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">广告位：</label>
      <div class="layui-input-block">
        <select name="adv_id">
          <option value="0">选择所属广告位</option> 
          {volist name='adv' id='vo'}
          <option value="{$vo.id}">{$vo.title}</option>
          {/volist}
          
        </select>
      </div>
    </div>
    
    <div class="layui-form-item">
      <label class="layui-form-label">上传图片：</label>
      <div class="layui-input-block">
        <input type="file" name="mfile" lay-ext="jpg|png|gif" class="layui-upload-file">
        {if condition="isset($info['pic']) && !empty($info['pic'])"}
        <div class="pic_box"><img src="{$info.pic}" height="100"></div>
        <input type="hidden" name="pic" class="pic_input" value="{$info.pic}">
        {else/}
        <div class="pic_box"></div>
        <input type="hidden" name="pic" class="pic_input" value="">
        {/if}
      </div>
      
    </div>    
    
    <div class="layui-form-item">
      <label class="layui-form-label">状态：</label>
      <div class="layui-input-block">
        <input type="radio" name="status" value="1" title="正常" checked>
        <input type="radio" name="status" value="0" title="禁用">
      </div>
    </div>
    
    <div class="layui-form-item">
       <label class="layui-form-label">描述：</label>
       <div class="layui-input-block">
         <textarea name="description" placeholder="请输入描述内容" class="layui-textarea">{$info.description|default=''}</textarea>
       </div>
    </div>
    
    <div class="layui-form-item">
      <div class="layui-input-block">
        <button class="layui-btn layui-btn-normal ajax-post-btn" lay-submit lay-filter="formDemo">提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
      </div>
    </div>
  </form>
</div>
<script src="__STATIC__/js/jquery.min.js" type="text/javascript" charset="utf-8"></script> 
<script src="__STATIC__/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="__STATIC__/js/common.js" type="text/javascript" charset="utf-8"></script> 
<script>
			
layui.use(['form','upload'], function() {
	var form = layui.form();
	form.render();
	//监听提交
	form.on('submit(formDemo)', function(data) {
		//layer.msg(JSON.stringify(data.field));
		ajax_post('edit-form',true,'iframe189','');
		return false;
	});
	
	layui.upload({
		url: "{:url('File/upload')}"
		,success: function(res, input){
			if(res.code == 1){
				layer.msg(res.msg);	
				$(input).parents('.layui-input-block').find('.pic_input').val(res.data.src);
				$(input).parents('.layui-input-block').find('.pic_box').html('<img src="'+res.data.src+'" height="100">');
			}else{
				layer.msg(res.msg);		
			}
		}
	});
	
});


$(function(){
	setValue("adv_id", {$info.adv_id|default=input('adv_id',0)});
});		
{present name="info.id"}
$(function(){
	
});
{/present}
</script>


</body>
</html>